package day14_100;

import day11_142.ListNode;

/**
 * @ClassName Solution
 * @Description TODO
 * @Author clockTown
 * @Date 2021/5/23 20:21
 * @Version 1.0
 */
public class Solution {
    public static boolean isSameTree(TreeNode p, TreeNode q) {
        String pString = stringTree(p);
        String qString = stringTree(q);
        return pString.equals(qString);
    }

    public static String stringTree(TreeNode tree){
        if (tree == null) {
            return "NULL";
        }
        String left = stringTree(tree.left);
        String right = stringTree(tree.right);
        String res = tree.val + left + right;
        return res;
    }

    public static void main(String[] args) {
        TreeNode p = new TreeNode(1);
        p.left = new TreeNode(1);
        System.out.println(p);

        TreeNode q = new TreeNode(1);
        q.right = new TreeNode(1);
        System.out.println(q);

        System.out.println(stringTree(p));
        System.out.println(stringTree(q));

    }
}
